package com.ywl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ywl.entity.Banner;
import com.ywl.mapper.BannerMapper;
import com.ywl.service.BannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ywl
 * @since 2022-08-26
 */
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {

    /**
     * 获取最新创建的前5个图片
     * @return
     */
    @Override
    public List<Banner> get() {
        LambdaQueryWrapper<Banner> qw = new LambdaQueryWrapper<>();
        qw.orderByDesc(Banner::getCreateTime);
        qw.last("limit 5");
        List<Banner> list = super.list(qw);
        return list;
    }
}
